//
//  leftItemView.m
//  MobileGameLiving2
//
//  Created by reflection on 15/9/6.
//  Copyright (c) 2015年 李旭东. All rights reserved.
//

#import "leftItemView.h"
#import "FRPGame.h"
#import "GameManager.h"
#import "GameLivingViewController.h"

@interface leftItemView()

@property (nonatomic,strong)FRPGame *game;

@end

@implementation leftItemView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

//-(FRPGame *)game{
//    if (!_game) {
//        _game = [GameManager videos][0];
//    }
//    return _game;
//}

//- (instancetype)initWithFrame:(CGRect)frame{
//    self = [super initWithFrame:frame];
//    if (self) {
//        [self setMainView];
//    }
//    return self;
//}

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setMainView];
    }
    return self;
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    if( self = [super initWithCoder:aDecoder]){
        if( self ){
            [self setMainView];
        }
    }
    return self;
}


- (void)setMainView{
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(3, 3, 175, 93)];
//    imageView.backgroundColor = [UIColor orangeColor];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(3, 98, 175, 10)];
    UIFont *font = [UIFont systemFontOfSize:13.0f];
//    label.text = @"张学友";
    label.font = font;
    
    [self addSubview:imageView];
    [self addSubview:label];
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTap:)];
    singleTap.numberOfTapsRequired = 1;
    [self addGestureRecognizer:singleTap];
    
    self.leftImageView = imageView;
    self.leftLabel = label;
}

- (void)singleTap:(UITapGestureRecognizer *)tapGesTure{
    NSLog(@"点击了view");
    if (_pageChangeDelegate && [_pageChangeDelegate respondsToSelector:@selector(pageDidClickWithPlayerName:)]) {
        [_pageChangeDelegate pageDidClickWithPlayerName:_leftLabel.text];
    }
    NSLog(@"%@",self.leftLabel.text);
}

@end
